package com.xmall.controller.wx;


import com.xmall.bean.table.Address;
import com.xmall.bean.vo.AddressDataVo;
import com.xmall.bean.vo.BaseRespVo;

import com.xmall.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("wx/address")
public class AddressController {
    @Autowired
    AddressService addressService;

    @RequestMapping("list")
    public BaseRespVo showAddressList(){
        List<AddressDataVo> addressDataVos = addressService.showAddressList();
        return BaseRespVo.ok(addressDataVos);
    }

    @RequestMapping("detail")
    public BaseRespVo showDetailById(Integer id){
        Map<String,Object> map = addressService.showDetailById(id);
        return BaseRespVo.ok(map);

    }
    @RequestMapping("save")
    public BaseRespVo saveAddressDetail(@RequestBody Address address){
        Integer id = addressService.saveAddressDetail(address);
        return BaseRespVo.ok(id);
    }
    @RequestMapping("delete")
    public BaseRespVo deleteAddressDetail(@RequestBody Map<String,Object> id){
        Integer id1 = (Integer) id.get("id");
        addressService.deleteAddressDetail(id1);
        return BaseRespVo.ok();
    }
}

